<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: Condition
  
    &mdash; Documentation by YARD 0.7.3
  
</title>

  <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />

  <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '';
  if (relpath != '') relpath += '/';
</script>

  <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="js/app.js"></script>


  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html">Index (C)</a> &raquo; 
    
    
    <span class="title">Condition</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a id="class_list_link" href="#">Class List</a>
  
    <a id="method_list_link" href="#">Method List</a>
  
    <a id="file_list_link" href="#">File List</a>
  
</div>
      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: Condition
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">ActiveRecord::Base</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">ActiveRecord::Base</li>
          
            <li class="next">Condition</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">app/models/condition.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>
ELMO - Secure, robust, and versatile data collection. Copyright 2011 The
Carter Center
</p>
<p>
ELMO is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
</p>
<p>
ELMO is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
</p>
<p>
You should have received a copy of the GNU General Public License along
with ELMO. If not, see &lt;http://www.gnu.org/licenses/&gt;.
</p>


  </div>
</div>
<div class="tags">
  

</div>
  <h2>Constant Summary</h2>
  
    <dl class="constants">
      
        <dt id="OPS-constant" class="">OPS =
          
        </dt>
        <dd><pre class="code"><span class='lbrace token'>{</span>
  <span class='string val'>&quot;is equal to&quot;</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrace token'>{</span><span class='symbol val'>:types</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='symbol val'>:decimal</span><span class='comma token'>,</span> <span class='symbol val'>:integer</span><span class='comma token'>,</span> <span class='symbol val'>:text</span><span class='comma token'>,</span> <span class='symbol val'>:long_text</span><span class='comma token'>,</span> <span class='symbol val'>:address</span><span class='comma token'>,</span> <span class='symbol val'>:select_one</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='symbol val'>:code</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;=&quot;</span><span class='rbrace token'>}</span><span class='comma token'>,</span>
  <span class='string val'>&quot;is less than&quot;</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrace token'>{</span><span class='symbol val'>:types</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='symbol val'>:decimal</span><span class='comma token'>,</span> <span class='symbol val'>:integer</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='symbol val'>:code</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;&lt;&quot;</span><span class='rbrace token'>}</span><span class='comma token'>,</span>
  <span class='string val'>&quot;is greater than&quot;</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrace token'>{</span><span class='symbol val'>:types</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='symbol val'>:decimal</span><span class='comma token'>,</span> <span class='symbol val'>:integer</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='symbol val'>:code</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;&gt;&quot;</span><span class='rbrace token'>}</span><span class='comma token'>,</span>
  <span class='string val'>&quot;is less than or equal to&quot;</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrace token'>{</span><span class='symbol val'>:types</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='symbol val'>:decimal</span><span class='comma token'>,</span> <span class='symbol val'>:integer</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='symbol val'>:code</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;&lt;=&quot;</span><span class='rbrace token'>}</span><span class='comma token'>,</span>
  <span class='string val'>&quot;is greater than or equal to&quot;</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrace token'>{</span><span class='symbol val'>:types</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='symbol val'>:decimal</span><span class='comma token'>,</span> <span class='symbol val'>:integer</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='symbol val'>:code</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;=&quot;</span><span class='rbrace token'>}</span><span class='comma token'>,</span>
  <span class='string val'>&quot;is not equal to&quot;</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrace token'>{</span><span class='symbol val'>:types</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='symbol val'>:decimal</span><span class='comma token'>,</span> <span class='symbol val'>:integer</span><span class='comma token'>,</span> <span class='symbol val'>:text</span><span class='comma token'>,</span> <span class='symbol val'>:long_text</span><span class='comma token'>,</span> <span class='symbol val'>:address</span><span class='comma token'>,</span> <span class='symbol val'>:select_one</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='symbol val'>:code</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;!=&quot;</span><span class='rbrace token'>}</span><span class='comma token'>,</span>
  <span class='string val'>&quot;includes&quot;</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrace token'>{</span><span class='symbol val'>:types</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='symbol val'>:select_multiple</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='symbol val'>:code</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;=&quot;</span><span class='rbrace token'>}</span><span class='comma token'>,</span>
  <span class='string val'>&quot;does not include&quot;</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrace token'>{</span><span class='symbol val'>:types</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='lbrack token'>[</span><span class='symbol val'>:select_multiple</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='symbol val'>:code</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;!=&quot;</span><span class='rbrace token'>}</span>
<span class='rbrace token'>}</span>
</pre></dd>
      
    </dl>
  


  


  

  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#all_fields_required-instance_method" title="#all_fields_required (instance method)">- (Object) <strong>all_fields_required</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#clear_blanks-instance_method" title="#clear_blanks (instance method)">- (Object) <strong>clear_blanks</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#conditionable_qings-instance_method" title="#conditionable_qings (instance method)">- (Object) <strong>conditionable_qings</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#duplicate-instance_method" title="#duplicate (instance method)">- (Object) <strong>duplicate</strong>(new_qing, qid_hash) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#has_options%3F-instance_method" title="#has_options? (instance method)">- (Boolean) <strong>has_options?</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#op_select_options-instance_method" title="#op_select_options (instance method)">- (Object) <strong>op_select_options</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#option_select_options-instance_method" title="#option_select_options (instance method)">- (Object) <strong>option_select_options</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#question_code_select_options-instance_method" title="#question_code_select_options (instance method)">- (Object) <strong>question_code_select_options</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#question_code_type_hash-instance_method" title="#question_code_type_hash (instance method)">- (Object) <strong>question_code_type_hash</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#question_options_hash-instance_method" title="#question_options_hash (instance method)">- (Object) <strong>question_options_hash</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#ref_question-instance_method" title="#ref_question (instance method)">- (Object) <strong>ref_question</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#to_odk-instance_method" title="#to_odk (instance method)">- (Object) <strong>to_odk</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#verify_ordering-instance_method" title="#verify_ordering (instance method)">- (Object) <strong>verify_ordering</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
    </ul>
  


  

  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="all_fields_required-instance_method">
  
    - (<tt>Object</tt>) <strong>all_fields_required</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


104
105
106</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 104</span>

<span class='def def kw'>def</span> <span class='all_fields_required identifier id'>all_fields_required</span>
  <span class='errors identifier id'>errors</span><span class='dot token'>.</span><span class='add identifier id'>add</span><span class='lparen token'>(</span><span class='symbol val'>:base</span><span class='comma token'>,</span> <span class='string val'>&quot;All fields are required.&quot;</span><span class='rparen token'>)</span> <span class='if if_mod kw'>if</span> <span class='ref_qing identifier id'>ref_qing</span><span class='dot token'>.</span><span class='blank? fid id'>blank?</span> <span class='orop op'>||</span> <span class='op identifier id'>op</span><span class='dot token'>.</span><span class='blank? fid id'>blank?</span> <span class='orop op'>||</span> <span class='lparen token'>(</span><span class='value identifier id'>value</span><span class='dot token'>.</span><span class='blank? fid id'>blank?</span> <span class='andop op'>&amp;&amp;</span> <span class='option_id identifier id'>option_id</span><span class='dot token'>.</span><span class='blank? fid id'>blank?</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="clear_blanks-instance_method">
  
    - (<tt>Object</tt>) <strong>clear_blanks</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


97
98
99
100
101
102
103</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 97</span>

<span class='def def kw'>def</span> <span class='clear_blanks identifier id'>clear_blanks</span>
  <span class='begin begin kw'>begin</span>
    <span class='self self kw'>self</span><span class='dot token'>.</span><span class='value identifier id'>value</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span> <span class='if if_mod kw'>if</span> <span class='value identifier id'>value</span><span class='dot token'>.</span><span class='blank? fid id'>blank?</span>
    <span class='self self kw'>self</span><span class='dot token'>.</span><span class='option_id identifier id'>option_id</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span> <span class='if if_mod kw'>if</span> <span class='option_id identifier id'>option_id</span><span class='dot token'>.</span><span class='blank? fid id'>blank?</span>
  <span class='rescue rescue kw'>rescue</span>
  <span class='end end kw'>end</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="conditionable_qings-instance_method">
  
    - (<tt>Object</tt>) <strong>conditionable_qings</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


36
37
38</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 36</span>

<span class='def def kw'>def</span> <span class='conditionable_qings identifier id'>conditionable_qings</span>
  <span class='questioning identifier id'>questioning</span> <span class='integer val'>? </span><span class='questioning identifier id'>questioning</span><span class='dot token'>.</span><span class='previous_qings identifier id'>previous_qings</span><span class='dot token'>.</span><span class='reject identifier id'>reject</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='qing identifier id'>qing</span><span class='bitor op'>|</span> <span class='dstring node'>%w[location]</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='qing identifier id'>qing</span><span class='dot token'>.</span><span class='question identifier id'>question</span><span class='dot token'>.</span><span class='type identifier id'>type</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='rparen token'>)</span><span class='rbrace token'>}</span> <span class='colon op'>:</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="duplicate-instance_method">
  
    - (<tt>Object</tt>) <strong>duplicate</strong>(new_qing, qid_hash) 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


70
71
72
73
74
75</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 70</span>

<span class='def def kw'>def</span> <span class='duplicate identifier id'>duplicate</span><span class='lparen token'>(</span><span class='new_qing identifier id'>new_qing</span><span class='comma token'>,</span> <span class='qid_hash identifier id'>qid_hash</span><span class='rparen token'>)</span>
  <span class='comment val'># look up the new ref_qing_id</span>
  <span class='new_ref_qing identifier id'>new_ref_qing</span> <span class='assign token'>=</span> <span class='qid_hash identifier id'>qid_hash</span><span class='lbrack token'>[</span><span class='ref_qing identifier id'>ref_qing</span><span class='dot token'>.</span><span class='question_id identifier id'>question_id</span><span class='rbrack token'>]</span>
  <span class='comment val'># initialize and return</span>
  <span class='new_qing identifier id'>new_qing</span><span class='dot token'>.</span><span class='build_condition identifier id'>build_condition</span><span class='lparen token'>(</span><span class='symbol val'>:ref_qing</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='new_ref_qing identifier id'>new_ref_qing</span><span class='comma token'>,</span> <span class='symbol val'>:op</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='op identifier id'>op</span><span class='comma token'>,</span> <span class='symbol val'>:value</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='value identifier id'>value</span><span class='comma token'>,</span> <span class='symbol val'>:option_id</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='option_id identifier id'>option_id</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="has_options?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>has_options?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


66
67
68</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 66</span>

<span class='def def kw'>def</span> <span class='has_options? fid id'>has_options?</span>
  <span class='ref_question identifier id'>ref_question</span> <span class='andop op'>&amp;&amp;</span> <span class='notop op'>!</span><span class='ref_question identifier id'>ref_question</span><span class='dot token'>.</span><span class='options identifier id'>options</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="op_select_options-instance_method">
  
    - (<tt>Object</tt>) <strong>op_select_options</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


56
57
58
59
60</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 56</span>

<span class='def def kw'>def</span> <span class='op_select_options identifier id'>op_select_options</span>
  <span class='ref_question identifier id'>ref_question</span> <span class='integer val'>? </span>
    <span class='OPS constant id'>OPS</span><span class='dot token'>.</span><span class='reject identifier id'>reject</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='op identifier id'>op</span><span class='comma token'>,</span> <span class='attribs identifier id'>attribs</span><span class='bitor op'>|</span> <span class='notop op'>!</span><span class='attribs identifier id'>attribs</span><span class='lbrack token'>[</span><span class='symbol val'>:types</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='ref_question identifier id'>ref_question</span><span class='dot token'>.</span><span class='type identifier id'>type</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='dot token'>.</span><span class='to_sym identifier id'>to_sym</span><span class='rparen token'>)</span><span class='rbrace token'>}</span><span class='dot token'>.</span><span class='collect identifier id'>collect</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='op identifier id'>op</span><span class='comma token'>,</span> <span class='attribs identifier id'>attribs</span><span class='bitor op'>|</span> <span class='lbrack token'>[</span><span class='op identifier id'>op</span><span class='comma token'>,</span><span class='op identifier id'>op</span><span class='rbrack token'>]</span><span class='rbrace token'>}</span> <span class='colon op'>:</span>
    <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="option_select_options-instance_method">
  
    - (<tt>Object</tt>) <strong>option_select_options</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


62
63
64</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 62</span>

<span class='def def kw'>def</span> <span class='option_select_options identifier id'>option_select_options</span>
  <span class='ref_question identifier id'>ref_question</span> <span class='integer val'>? </span><span class='ref_question identifier id'>ref_question</span><span class='dot token'>.</span><span class='select_options identifier id'>select_options</span> <span class='colon op'>:</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="question_code_select_options-instance_method">
  
    - (<tt>Object</tt>) <strong>question_code_select_options</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


40
41
42</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 40</span>

<span class='def def kw'>def</span> <span class='question_code_select_options identifier id'>question_code_select_options</span>
  <span class='conditionable_qings identifier id'>conditionable_qings</span><span class='dot token'>.</span><span class='collect identifier id'>collect</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='qing identifier id'>qing</span><span class='bitor op'>|</span> <span class='lbrack token'>[</span><span class='dstring node'>&quot;#{qing.rank}. #{qing.question.code}&quot;</span><span class='comma token'>,</span> <span class='qing identifier id'>qing</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='rbrack token'>]</span><span class='rbrace token'>}</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="question_code_type_hash-instance_method">
  
    - (<tt>Object</tt>) <strong>question_code_type_hash</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


44
45
46</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 44</span>

<span class='def def kw'>def</span> <span class='question_code_type_hash identifier id'>question_code_type_hash</span>
  <span class='Hash constant id'>Hash</span><span class='lbrack token'>[</span><span class='mult op'>*</span><span class='conditionable_qings identifier id'>conditionable_qings</span><span class='dot token'>.</span><span class='collect identifier id'>collect</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='qing identifier id'>qing</span><span class='bitor op'>|</span> <span class='lbrack token'>[</span><span class='qing identifier id'>qing</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='comma token'>,</span> <span class='qing identifier id'>qing</span><span class='dot token'>.</span><span class='question identifier id'>question</span><span class='dot token'>.</span><span class='type identifier id'>type</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='rbrack token'>]</span><span class='rbrace token'>}</span><span class='dot token'>.</span><span class='flatten identifier id'>flatten</span><span class='rbrack token'>]</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="question_options_hash-instance_method">
  
    - (<tt>Object</tt>) <strong>question_options_hash</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


48
49
50
51
52
53
54</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 48</span>

<span class='def def kw'>def</span> <span class='question_options_hash identifier id'>question_options_hash</span>
  <span class='hash identifier id'>hash</span> <span class='assign token'>=</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span>
  <span class='conditionable_qings identifier id'>conditionable_qings</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='qing identifier id'>qing</span><span class='bitor op'>|</span> 
    <span class='hash identifier id'>hash</span><span class='lbrack token'>[</span><span class='qing identifier id'>qing</span><span class='dot token'>.</span><span class='id identifier id'>id</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='qing identifier id'>qing</span><span class='dot token'>.</span><span class='question identifier id'>question</span><span class='dot token'>.</span><span class='select_options identifier id'>select_options</span> <span class='if if_mod kw'>if</span> <span class='qing identifier id'>qing</span><span class='dot token'>.</span><span class='question identifier id'>question</span><span class='dot token'>.</span><span class='options identifier id'>options</span>
  <span class='end end kw'>end</span>
  <span class='hash identifier id'>hash</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="ref_question-instance_method">
  
    - (<tt>Object</tt>) <strong>ref_question</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


77
78
79</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 77</span>

<span class='def def kw'>def</span> <span class='ref_question identifier id'>ref_question</span>
  <span class='ref_qing identifier id'>ref_qing</span> <span class='integer val'>? </span><span class='ref_qing identifier id'>ref_qing</span><span class='dot token'>.</span><span class='question identifier id'>question</span> <span class='colon op'>:</span> <span class='nil nil kw'>nil</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="to_odk-instance_method">
  
    - (<tt>Object</tt>) <strong>to_odk</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


85
86
87
88
89
90
91
92
93
94</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 85</span>

<span class='def def kw'>def</span> <span class='to_odk identifier id'>to_odk</span>
  <span class='if if kw'>if</span> <span class='has_options? fid id'>has_options?</span>
    <span class='xpath identifier id'>xpath</span> <span class='assign token'>=</span> <span class='dstring node'>&quot;selected(/data/#{ref_question.code}, '#{option_id}')&quot;</span>
    <span class='xpath identifier id'>xpath</span> <span class='assign token'>=</span> <span class='dstring node'>&quot;not(#{xpath})&quot;</span> <span class='if if_mod kw'>if</span> <span class='OPS constant id'>OPS</span><span class='lbrack token'>[</span><span class='op identifier id'>op</span><span class='rbrack token'>]</span><span class='lbrack token'>[</span><span class='symbol val'>:code</span><span class='rbrack token'>]</span> <span class='eq op'>==</span> <span class='string val'>&quot;!=&quot;</span>
  <span class='else else kw'>else</span>
    <span class='val_str identifier id'>val_str</span> <span class='assign token'>=</span> <span class='ref_question identifier id'>ref_question</span><span class='dot token'>.</span><span class='type identifier id'>type</span><span class='dot token'>.</span><span class='numeric? fid id'>numeric?</span> <span class='integer val'>? </span><span class='value identifier id'>value</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span> <span class='colon op'>:</span> <span class='dstring node'>&quot;'#{value}'&quot;</span>
    <span class='xpath identifier id'>xpath</span> <span class='assign token'>=</span> <span class='dstring node'>&quot;/data/#{ref_question.code} #{OPS[op][:code]} #{val_str}&quot;</span>
  <span class='end end kw'>end</span>
  <span class='xpath identifier id'>xpath</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="verify_ordering-instance_method">
  
    - (<tt>Object</tt>) <strong>verify_ordering</strong> 
  

  
</p><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


81
82
83</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/condition.rb', line 81</span>

<span class='def def kw'>def</span> <span class='verify_ordering identifier id'>verify_ordering</span>
  <span class='raise identifier id'>raise</span> <span class='string val'>&quot;The new rankings invalidate one or more conditions&quot;</span> <span class='if if_mod kw'>if</span> <span class='questioning identifier id'>questioning</span><span class='dot token'>.</span><span class='rank identifier id'>rank</span> <span class='leq op'>&lt;=</span> <span class='ref_qing identifier id'>ref_qing</span><span class='dot token'>.</span><span class='rank identifier id'>rank</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Thu Dec  8 13:43:20 2011 by 
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.7.3 (ruby-1.8.7).
</div>

  </body>
</html>